<?php
    class MySQL {
        private $dbuser = 'avild001_rfuser';
        private $dbpass = 'rfpassdb';
        
        private $dbname = 'avild001_rfmantencion';

        private $dbhost = 'localhost:3306';
        private $conn;

        public function __construct() {
            if (!isset($this->conn)) {
                $this->conn = (mysql_connect($this->dbhost, $this->dbuser, $this->dbpass)) or die (mysql_error());
                mysql_select_db($this->dbname, $this->conn) or die (mysql_error());
            }
        }

        public function query($q) {
            $result = mysql_query($q, $this->conn);
            if(!$result) {
                echo 'mySQL error : ' . mysql_error();
                exit;
            }
            return $result;
        }

        public function fetch_array($q) {
            return mysql_fetch_array($q);
        }

        public function num_rows($q) {
            return mysql_num_rows($q);
        }

        public function affected_rows() {
            return mysql_affected_rows($this->conn);
        }

        public function fetch_assoc($q) {
            return mysql_fetch_assoc($q);
        }
    }
?>
